package com.netease.pris.activity.view;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.Adapter;
import android.widget.AdapterView;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.netease.g.b;

public class NPullToFreshContainer extends FrameLayout
  implements Animation.AnimationListener
{
  private static final boolean a;
  private int b = 0;
  private final int c = 0;
  private final int d = 1;
  private final int e = 2;
  private final int f = 3;
  private final int g = 4;
  private int h = 0;
  private ImageView i;
  private TextView j;
  private TextView k;
  private RotateAnimation l;
  private RotateAnimation m;
  private View n;
  private float o;
  private int p;
  private ProgressBar q;
  private MotionEvent r;
  private bn s;
  private o t;
  private String u;
  private boolean v = true;
  private int w = 0;
  private boolean x;

  public NPullToFreshContainer(Context paramContext)
  {
    super(paramContext);
    a(paramContext);
  }

  public NPullToFreshContainer(Context paramContext, AttributeSet paramAttributeSet)
  {
    super(paramContext, paramAttributeSet);
    a(paramContext);
  }

  public NPullToFreshContainer(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
  {
    super(paramContext, paramAttributeSet, paramInt);
    a(paramContext);
  }

  private void a(Context paramContext)
  {
    setDrawingCacheEnabled(false);
    this.n = LayoutInflater.from(getContext()).inflate(2130903062, null);
    this.n.setVisibility(4);
    this.n.setBackgroundColor(16250872);
    this.i = ((ImageView)this.n.findViewById(2131558463));
    this.i.setScaleType(ImageView.ScaleType.FIT_CENTER);
    float f1 = paramContext.getResources().getDisplayMetrics().density;
    this.i.setMinimumHeight((int)(f1 * 50.0F));
    this.j = ((TextView)this.n.findViewById(2131558464));
    this.k = ((TextView)this.n.findViewById(2131558465));
    this.k.setVisibility(0);
    this.q = ((ProgressBar)this.n.findViewById(2131558462));
    this.m = new RotateAnimation(0.0F, -180.0F, 1, 0.5F, 1, 0.5F);
    this.m.setInterpolator(new LinearInterpolator());
    this.m.setDuration(250L);
    this.m.setFillAfter(true);
    this.m.setAnimationListener(this);
    this.l = new RotateAnimation(-180.0F, 0.0F, 1, 0.5F, 1, 0.5F);
    this.l.setInterpolator(new LinearInterpolator());
    this.l.setDuration(250L);
    this.l.setFillAfter(true);
    addView(this.n, new ViewGroup.LayoutParams(-1, -2));
    this.t = new o(this);
  }

  private void c()
  {
    this.t.a(-this.p - this.b, 250);
  }

  private void d()
  {
    if (this.p == 0);
    while (true)
    {
      return;
      this.t.a(-this.p, 250);
    }
  }

  public void a()
  {
    this.h = 3;
    c();
    b();
  }

  public void a(bn parambn)
  {
    this.s = parambn;
  }

  public void a(String paramString)
  {
    b(paramString);
  }

  public void b()
  {
    if (this.s != null)
      this.s.a();
  }

  public void b(String paramString)
  {
    c(paramString);
    if (this.p != 0)
      d();
    this.h = 0;
  }

  public void c(String paramString)
  {
    if (paramString == null);
    while (true)
    {
      return;
      this.u = paramString;
    }
  }

  protected void dispatchDraw(Canvas paramCanvas)
  {
    super.dispatchDraw(paramCanvas);
    View localView1 = getChildAt(0);
    View localView2 = getChildAt(1);
    switch (this.h)
    {
    default:
    case 0:
    case 1:
    case 2:
    case 3:
    case 4:
    }
    while (true)
    {
      return;
      localView1.setVisibility(4);
      localView2.layout(0, 0, getMeasuredWidth(), getMeasuredHeight());
      continue;
      localView1.setVisibility(0);
      localView2.offsetTopAndBottom(-this.p - localView2.getTop());
      localView1.setVisibility(0);
      this.q.setVisibility(4);
      localView1.offsetTopAndBottom(-this.b - this.p - localView1.getTop());
      if (this.h == 1)
        this.j.setText(2131362300);
      while (true)
      {
        if (this.u == null)
          break label180;
        this.k.setText(this.u);
        break;
        this.j.setText(2131362299);
      }
      label180: continue;
      localView1.setVisibility(0);
      localView2.offsetTopAndBottom(-this.p - localView2.getTop());
      int i2 = localView1.getTop();
      localView2.layout(localView2.getLeft(), localView2.getTop(), localView2.getRight(), getHeight());
      this.q.setVisibility(0);
      this.i.clearAnimation();
      this.i.setVisibility(4);
      this.j.setText(2131362301);
      if (this.u != null)
        this.k.setText(this.u);
      localView1.offsetTopAndBottom(-this.b - this.p - i2);
      continue;
      localView2.invalidate();
      localView2.offsetTopAndBottom(-this.p - localView2.getTop());
      int i1 = localView1.getTop();
      localView2.layout(localView2.getLeft(), localView2.getTop(), localView2.getRight(), getHeight());
      this.q.setVisibility(0);
      this.k.setVisibility(0);
      this.j.setText(2131362301);
      localView1.offsetTopAndBottom(-this.b - this.p - i1);
    }
  }

  public boolean dispatchTouchEvent(MotionEvent paramMotionEvent)
  {
    if (this.x)
    {
      paramMotionEvent.setAction(3);
      super.dispatchTouchEvent(paramMotionEvent);
    }
    int i1;
    AdapterView localAdapterView;
    for (boolean bool = true; ; bool = true)
    {
      return bool;
      i1 = 0xFF & paramMotionEvent.getAction();
      localAdapterView = (AdapterView)getChildAt(1);
      Adapter localAdapter = localAdapterView.getAdapter();
      if ((localAdapter != null) && (localAdapter.getCount() != 0))
        break;
    }
    float f1 = paramMotionEvent.getY();
    paramMotionEvent.getX();
    label112: float f2;
    int i3;
    switch (i1)
    {
    default:
    case 0:
      while (true)
      {
        bool = super.dispatchTouchEvent(paramMotionEvent);
        break;
        this.o = f1;
        if (this.r != null)
          this.r.recycle();
        this.r = MotionEvent.obtain(paramMotionEvent);
      }
    case 2:
      f2 = this.o - f1;
      this.o = f1;
      i3 = localAdapterView.getFirstVisiblePosition();
      if (localAdapterView.getChildCount() <= 0)
        break;
    case 1:
    case 3:
    }
    for (int i4 = localAdapterView.getChildAt(0).getTop(); ; i4 = 0)
    {
      if (this.h == 3)
      {
        if (this.r.getY() - f1 <= 0.0F)
        {
          bool = super.dispatchTouchEvent(paramMotionEvent);
          break;
        }
        this.h = 4;
      }
      if (this.h == 4)
      {
        int i5 = this.p + (int)(f2 / 1.7F);
        if ((i3 == 0) && (this.p == -this.b) && (f2 < 0.0F))
        {
          bool = super.dispatchTouchEvent(paramMotionEvent);
          break;
        }
        if ((i5 > -this.b) && (i5 < 0) && (this.p < 0))
        {
          this.p = i5;
          invalidate();
          bool = true;
          break;
        }
        if ((i5 > 0) && (this.p < 0))
        {
          this.p = 0;
          invalidate();
          bool = true;
          break;
        }
        b.c("dispatchevent", "top: " + i4);
        if ((i3 == 0) && (this.p == 0) && (f2 < 0.0F) && (i4 == this.w))
        {
          b.c("dispatchevent", "position == 0 && mPadding == 0 && scrollY < 0:  newPadding: " + i5);
          if (i5 < 0)
          {
            this.p = i5;
            invalidate();
            bool = true;
            break;
          }
        }
        else
        {
          if ((i3 == 0) && (i5 < 0) && (i4 == this.w))
          {
            this.p = i5;
            invalidate();
            bool = true;
            break;
          }
          if ((i3 == 0) && (i5 > 0))
            this.p = 0;
        }
        bool = super.dispatchTouchEvent(paramMotionEvent);
        break;
      }
      if ((i3 == 0) && (((i4 == this.w) && (f2 < 0.0F)) || (localAdapterView.getTop() > 0)))
      {
        this.p += (int)f2 / 2;
        if ((this.p > -this.b) && (this.p < 0) && ((this.h == 0) || (this.h == 1) || (this.h == 2)))
        {
          this.q.setVisibility(4);
          this.i.setVisibility(0);
          if (this.h == 2)
          {
            this.i.clearAnimation();
            this.i.startAnimation(this.l);
          }
        }
        for (this.h = 1; ; this.h = 2)
        {
          do
          {
            invalidate();
            if (this.p != 0)
              paramMotionEvent.setAction(3);
            bool = super.dispatchTouchEvent(paramMotionEvent);
            break;
          }
          while ((this.p > -this.b) || (this.h != 1));
          this.q.setVisibility(4);
          this.i.setVisibility(0);
          this.i.clearAnimation();
          this.i.startAnimation(this.m);
        }
      }
      if ((this.h != 1) && (this.h != 2))
        break label112;
      paramMotionEvent.setAction(3);
      bool = super.dispatchTouchEvent(paramMotionEvent);
      break;
      if ((localAdapterView.getFirstVisiblePosition() == 0) && (localAdapterView.getTop() > 0) && (this.h == 2))
      {
        this.h = 3;
        c();
        b();
        paramMotionEvent.setAction(3);
        break label112;
      }
      if (this.h == 3)
      {
        c();
        break label112;
      }
      if (this.h == 4)
      {
        int i2 = getChildAt(0).getBottom();
        if (i2 >= this.b)
        {
          c();
          paramMotionEvent.setAction(3);
          bool = super.dispatchTouchEvent(paramMotionEvent);
          break;
        }
        if ((i2 <= 0) || (i2 >= this.b))
          break label112;
        d();
        paramMotionEvent.setAction(3);
        bool = super.dispatchTouchEvent(paramMotionEvent);
        break;
      }
      d();
      this.h = 0;
      break label112;
    }
  }

  public void onAnimationEnd(Animation paramAnimation)
  {
  }

  public void onAnimationRepeat(Animation paramAnimation)
  {
  }

  public void onAnimationStart(Animation paramAnimation)
  {
  }

  protected void onLayout(boolean paramBoolean, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    getChildAt(0).layout(0, -this.b - this.p, getMeasuredWidth(), -this.p);
    getChildAt(1).layout(0, -this.p, getMeasuredWidth(), getMeasuredHeight());
    if ((this.v) || (this.b == 0))
    {
      this.b = getChildAt(0).getMeasuredHeight();
      AdapterView localAdapterView = (AdapterView)getChildAt(1);
      if ((localAdapterView.getCount() > 0) && (localAdapterView.getChildAt(0) != null))
        this.w = localAdapterView.getChildAt(0).getTop();
      this.v = false;
    }
  }

  protected void onMeasure(int paramInt1, int paramInt2)
  {
    super.onMeasure(paramInt1, paramInt2);
  }
}

/* Location:           D:\android\hack\dex2jar-0.0.9.8\classes_dex2jar.jar
 * Qualified Name:     com.netease.pris.activity.view.NPullToFreshContainer
 * JD-Core Version:    0.6.0
 */